package com.tan.exception;

import com.tan.response.ResultCode;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @author NieChangan
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class BusinessException extends RuntimeException{

    @ApiModelProperty(value = "状态码")
    private Integer code;

    @ApiModelProperty(value = "错误信息")
    private String errMsg;

    @ApiModelProperty(value = "错误信息对象")
    private ResultCode resultCode;

    public BusinessException(ResultCode resultCode){
        code = resultCode.getCode();
        errMsg = resultCode.getMessage();
        this.resultCode = resultCode;
    }
}